package com.googlecode.afx.utils;

import com.googlecode.afx.view.NodeHandler;

import javafx.scene.Node;

public class FindByNodeIdHandler implements NodeHandler {

	private String id;
	
	private boolean found = false;
	
	private Node result = null;
	
	public FindByNodeIdHandler(String id) {
		this.id = id;
	}

	@Override
	public void process(Node node) {
		if(node.getId() != null && node.getId().equals(this.id)) {
			this.result = node;
			this.found = true;
		}
	}

	@Override
	public boolean continueTraversing() {
		return !found;
	}
	
	public Node getResult() {
		return this.result;
	}

	public boolean hasFound() {
		return found;
	}

}
